///引入依赖
const mysql = require('mysql2');
const config = {
	user: 'root', //用户名
	password: 'root', //密码
	host: 'localhost', //ip地址
	database: 'interview', //数据库名称
	port: 3306,
	connectionLimit : 10 
}
const pool = new mysql.createPool(config)

//方法对象
const units = {
	query: function(sql, params) {
		return new Promise((resolve, reject)=>{
			pool.query(sql, params, function (error, results, fields) {
			  if (error) reject(error);
			  else resolve(results)
			});
		})
	}
}
module.exports = units;
